package com.example.imagepro;

import com.example.imagepro.utils.ImageUtils;
import javafx.scene.image.Image;
import org.junit.Test;
import sun.java2d.pipe.SpanIterator;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileInputStream;
import java.util.Arrays;
import java.util.Random;

public class test {
    public static void main(String[] args) {
        File backfile = new File("D:\\新建文件夹\\背景图片\\");
        File file = new File("D:\\新建文件夹\\机械图片\\");
        String url = "D:\\新建文件夹\\合成之后";
        File[] backfiles = backfile.listFiles();
        File[] files = file.listFiles();
        int i = 0;
        int bs=50;
        while (i < 2) {
            Integer w = Double.valueOf(Math.random() * 100).intValue();
            Integer h = Double.valueOf(Math.random() * 100).intValue();
            Arrays.stream(backfiles).forEach(f -> {
                String path = f.getPath();
                Arrays.stream(files).forEach(fs -> {
                    try {
                        BufferedImage sourceImg = ImageIO.read(new FileInputStream(fs.getPath()));
                        int hh = sourceImg.getHeight()/2;
                        int ww = sourceImg.getWidth()/2;
                        ImageUtils.signatureSynthesis(path, fs.getPath(), url +File.separator + System.currentTimeMillis() + ".jpg", w, h,ww,hh);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                });
            });
            i++;
        }

//        try {
//            ImageUtils.signatureSynthesis("D:\\新建文件夹\\背景图片\\13213265465.JPG","D:\\新建文件夹\\机械图片\\20210923102412.jpg","D:\\新建文件夹\\123123.jpg",140,210);
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
    }
    /**
     *          * @param imgPath       图片路径
     *          * @param signaturePath 签名图片路径
     *          * @param outFilePath   合成后图片路径
     *          * @param xPlace        签名图片放置的x坐标
     *          * @param yPlace        签名图片放置的y坐标
     */
}
